import type { CursorPage, SimpleUserView } from "../types";

export type ArticleCreateInput = {
  title: string;
  content: string;
};

export type ArticleUpdateInput = {
  title: string;
  content: string;
};

export type ArticlesGetInput = {
  cursor?: string;
  count: number;
};

export type ArticleView = {
  uid: string;
  title: string;
  content: string;
  createdAt: string;
  author?: SimpleUserView | null | undefined;
};

export type ArticleCreateFn = (input: ArticleCreateInput) => Promise<string>;

export type ArticleUpdateFn = (uid: string, input: ArticleUpdateInput) => Promise<string>;

export type ArticleGetFn = (uid: string) => Promise<ArticleView>;

export type ArticlesGetFn = (input: ArticlesGetInput) => Promise<CursorPage<ArticleView, string>>;

export type ArticleApis = {
  articleCreate: ArticleCreateFn;
  articleUpdate: ArticleUpdateFn;
  articleGet: ArticleGetFn;
  articlesGet: ArticlesGetFn;
};
